from exts import db
from common import constant
from common.base_model import BasicModelMixin, \
    CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin

MIDDLE_DB_STR_LEN = constant.MIDDLE_DB_STR_LEN
LONG_DB_STR_LEN = constant.LONG_DB_STR_LEN


class OperationLog(db.Model, BasicModelMixin,
              CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin):
    """"""
    __tablename__ = 'operation_log'

    id = db.Column(db.Integer, primary_key=True)
    operation_log_type = db.Column(
        db.String(constant.MIDDLE_DB_STR_LEN), default=constant.OperationLogType.SPU)
    parent_id = db.Column(db.Integer)

    action_str = db.Column(
        db.String(constant.MIDDLE_DB_STR_LEN), default=constant.OperationAction.CREATE)

    creator = db.relationship("User", foreign_keys='OperationLog.creator_id')
    updater = db.relationship("User", foreign_keys='OperationLog.updater_id')





